package com.woniuxy.oldmanapi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.oldmanapi.entity.Card;
import com.woniuxy.oldmanapi.mapper.CardMapper;
import com.woniuxy.oldmanapi.vo.CardVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CardService {

    @Autowired
    CardMapper cardMapper ;

    public PageInfo<CardVo> findCardByPage(Integer now, Integer size,Integer balanceStatus,Integer status, String name) {
        PageHelper.startPage(now,size);
        List<CardVo> CardVoList =  cardMapper.selectCardByCons(balanceStatus,status,name);
        return new PageInfo<>(CardVoList);
    }

    public List<Card> findCardById(int id) {
        return cardMapper.selectCardById(id);
    }

    public void guashi(int id) {
        cardMapper.guashi(id);
    }

    public void dongjie(int id) {
        cardMapper.dongjie(id);
    }
    public void zhuxiao(int id) {
        cardMapper.zhuxiao(id);
    }

    public void jiegua(int id) {
        cardMapper.jiegua(id);
    }
    public void add(Card card) {
        cardMapper.insert(card);
    }

    public int selectMaxId() {
        return cardMapper.selectMaxId();
    }

    public void updateBalance(Long num, Integer cardId) {
        cardMapper.updateBalance(num,cardId);
    }

    public CardVo selectOne(int id) {
        return cardMapper.selectOneById(id);
    }

    public Integer findIdByNumber(String number) {
        return cardMapper.selectByNumber(number);
    }

    public Card selectCard(Integer id) {
        return cardMapper.selectByPrimaryKey(id);
    }
}
